package org.dkakunsi.aplikasitoko.form;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

import org.dkakunsi.aplikasitoko.service.DataService;

/**
 *
 * @author dkakunsi
 */
public class Splash extends JWindow {

	private static final long serialVersionUID = 1L;
    private final int DURASI = 3000;

    public Splash() {
    	super();
    	setter();
    }
    
    @SuppressWarnings("deprecation")
	private void setter() {
        this.setVisible(true);
        getContentPane().setLayout(null);

        JPanel content = new JPanel();
        content = (JPanel) getContentPane();
        content.setBackground(Color.white);
        int width  = 495;
        int height = 347;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width-width)/2;
        int y = (screen.height-height)/2;
        setBounds(x, y, width,height);
        ImageIcon splashImage = new ImageIcon( getClass().getResource( "/icon/Splash.png" ) );
        Image img = splashImage.getImage();
        BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.createGraphics();
        g.drawImage(img, 10, 0, img.getWidth(null), img.getHeight(null), null);
        ImageIcon newIcon = new ImageIcon(bi);
        JLabel label = new JLabel(newIcon);
        label.setBounds(0, 25, img.getWidth(null), img.getHeight(null));
        
        JLabel AURORA = new JLabel("Aplikasi TOKO");
        AURORA.setBounds(10, 0, 200, 25);
        AURORA.setFont(new Font("Sans-Serif", Font.BOLD, 12));
        JLabel label2 = new JLabel("Copyright 2012, dKakunsi Licensed", JLabel.CENTER);
        label2.setBounds(0, 315, 347, 25);
        label2.setFont(new Font("Sans-Serif", Font.ITALIC, 12));
        content.add(label);
        content.add(label2);
        content.add(AURORA);
        Color warnaBorder =  Color.BLACK;
        content.setBorder(BorderFactory.createLineBorder(warnaBorder, 5));

        DataService ds = new DataService();
        ds.initialize();
        
        try {
            Thread.sleep(DURASI);
        } catch (InterruptedException ex) {
        }

        this.setVisible(false);
        this.dispose();
        new Login().show(true);
    }
}